<template>
  <!--<div class="ris_nav pg_nav bg_black" v-show="HeaderFlag">-->
  <div>

<!--//  修改码框-->
    <div class="cp_modal" v-show="password_show">
      <div>
        <h1 class="cp_head">修改密码</h1>
        <table class="cp_table">
          <tr>
            <td>用户名</td>
            <td><input type="text" v-model="user.username" readonly/></td>
          </tr>
          <tr>
            <td>输入密码</td>
            <td><input type="password" v-model="enter_password"/></td>
          </tr>
          <tr>
            <td>确认密码</td>
            <td><input type="password" v-model="confirm_password"/></td>
          </tr>
        </table>
        <div class="cp_footBtn">
          <button class="button btn_blur" @click="confirm_button()">确认修改</button>
          <button class="button btn_yellow" @click="abolish()">取消修改</button>
        </div>
      </div>
    </div>





  <div class="ris_nav pg_nav bg_black">
    <div class="nav_cont clear">
      <!--logo-->
      <div class="nav_lofo">
        <!--<img src="./img/nav_logo_02.jpg"/>-->
      </div>
      <!--导航-->
      <ul class="nav_ul">
        <li :class="pageIndex == index?'nav_avtive':''" v-for="(item,index) in menuList" @mouseover="item.showChildren=true" @mouseleave="item.showChildren=false" @click="jump1(index, item.children, item.title)">
          <!--<p>-->
            <!--<img :src="item.title | icon">-->
          <!--</p>-->
          <a>{{item.title}}</a>
          <ul v-show="item.showChildren">
            <li v-for="item2 in item.children" @click="jump2(index, item2.title)">{{item2.title}}</li>
          </ul>
        </li>
      </ul>
      <!--右边设置-->
      <div class="nav_search">
        <ul @mouseleave="sysFlag=false">
          <!--<li><img src="../../../static/img/header/tishi_03.png"></li>-->
          <li  @click="sysFlag=true">
            <!--<img src="../../../static/img/header/shezhi_05.png">-->
            <!--管理员-->
            <span v-text="name"></span><img src="../../../static/img/header/down.png" style="height: 6px;padding: 0 10px;"/>
            <ul v-show="sysFlag">
              <li @click="update_password()">修改密码</li>
              <li @click="logout">注销登录</li>
              <!--<li v-for="item in menuList">{{item.title}}</li>-->
              <!--<li>二级菜单1</li>-->
              <!--<li>二级菜单1</li>-->
              <!--<li>二级菜单1</li>-->
            </ul>
          </li>
        </ul>
      </div>
    </div>

  </div>
  <!--<div class="ris_cont_head">-->
    <!--<div class="ris_cont_head_left">-->
      <!--<p class="ts_Text"><img src="../../../static/img/header/tishiText_06.png"/><span v-text="timeSlot"></span><span v-text="name"></span></p>-->
      <!--&lt;!&ndash;<p>首页&gt;登记</p>&ndash;&gt;-->
    <!--</div>-->
    <!--<div class="ris_cont_head_right">-->
      <!--<p>当前时间：<span v-text="nowTime"></span></p>-->
      <!--<p class="zhuxiaoLogin" @click="logout">注销登录<img src="../../../static/img/header/zhuxiao_03.png"/></p>-->
    <!--</div>-->
  <!--</div>-->
    <!--<div class="ris_footer pg_foot">&copy;Copyright&nbsp;2017&nbsp;&nbsp;北京金风易通科技有限公司&nbsp;&nbsp;版权所有</div>-->
  </div>
  <!--<div class="ris_footer pg_foot">&copy;Copyright&nbsp;2017&nbsp;&nbsp;北京金风易通科技医疗有限公司&nbsp;&nbsp;版权所有</div>-->
</template>

<script>

  import {logout} from '@/api/login'
  import {getMenu, test} from '@/api/user'
  import img1 from '../../../static/img/header/dj.png'
  import img2 from '../../../static/img/header/yuepian_05.png'
  import img3 from '../../../static/img/header/zdsz_06.png'
  import img4 from '../../../static/img/header/yxqp_06.png'
  import img5 from '../../../static/img/header/shezhi_05.png'
  import img6 from '../../../static/img/header/bgfp_08.png'
  import img7 from '../../../static/img/header/search_06.png'

  // import dj from '@/components/Header/img/dj.png'

    export default {
      name: "header",
      data(){
        return {
          sysFlag: false,
          menuFlag: false,
          menuList: '',
          pageIndex: '',
          timeSlot: '',
          nowTime: '',
          name: '',

          //用户 修改获得id
          user:"",
          userid:"",
//          输入密码
          enter_password:"",
//          确认密码
          confirm_password:"",
          // 修改密码show
          password_show:false,


        }
      },
      created() {
        // this.getTime()
        //时间赋值
         var date = new Date();
         var hour = date.getHours();
         var dateSx="";
         // console.log(1111111);
         if (hour >= 6 && hour < 8) {
           dateSx = "早上好！";
         } else if (hour >= 8 && hour < 11) {
           // console.log(hour);
           dateSx = "上午好！";
           // console.log(dateSx);
         } else if (hour >= 11 && hour < 13) {
           dateSx = "中午好！";
         } else if (hour >= 13 && hour < 18) {
           dateSx = "下午好！";
         } else {
           dateSx = "晚上好！";
         }
        // var d = new Date(),str = '';
        // str += d.getFullYear()+'年';
        // str  += d.getMonth() + 1+'月';
        // str  += d.getDate()+'日';
        // str += d.getHours()+'时';
        // str  += d.getMinutes()+'分';
        // str+= d.getSeconds()+'秒';

        this.timeSlot = dateSx;
        // this.nowTime = str;


        this.pageIndex = window.localStorage.page;

        return new Promise((resolve, reject) => {
          getMenu().then(response => {

            for(var i in response.data){
              response.data[i].showChildren=false;
            }
            this.menuList = response.data;
            this.name = response.name;
            resolve()
          }).catch(error => {
            reject(error)
          })
        });

      },
      methods:{
        //关闭打开注销
        sysFlagtrue(){
          if(this.sysFlag==false){
            this.sysFlag=true
          }else {
            this.sysFlag=false;
          }
        },
        update_password(){
//          console.log("asdasdas1")
          this.sysFlag=false;
          this.password_show=true;
          this.$http.get(window.localStorage.url+"/BaseSysUser/findByCodeUser")
            .then(function (res) {
              this.user=res.data.data;
              this.userid=res.data.data.id;
            });
//                if(res.data.status=='SUCCESS') {
//                  this.depts=res.data.data;
//                }

        },
//        确认修改
        confirm_button(){
//          console.log(this.userid,this.enter_password,this.confirm_password);//输入密码，确认密码！
          this.$http.get(window.localStorage.url+"/BaseSysUser/updatePassword?enter_password="+this.enter_password+"&confirm_password="+this.confirm_password+"&id="+this.userid)
            .then(function (res) {
              if(res.data.status=='SUCCESS') {
                this.password_show=false;
                $pg.popup({
                  text:res.data.data, //显示的文本
                  btnClass: 'delete', //确定按钮的类值  必传  方便查找确定按钮的class值reBtn
                  btnBgColor: '#4f56a3', //按钮的颜色
                  btnToggle: {
                    btnDetermine: true, //确定按钮是否显示
                    btnCancel: false, //取消按钮是否显示
                  },
                  determine: function() {

                  }, //点击确定执行的方法
                });

              }else{

                $pg.popup({
                  text:res.data.data, //显示的文本
                  btnClass: 'delete', //确定按钮的类值  必传  方便查找确定按钮的class值reBtn
                  btnBgColor: '#4f56a3', //按钮的颜色
                  btnToggle: {
                    btnDetermine: true, //确定按钮是否显示
                    btnCancel: false, //取消按钮是否显示
                  },
                  determine: function() {

                  }, //点击确定执行的方法
                });

              }
            });




        },

      //取消修改密码
        abolish(){
          this.password_show=false;
        },
        logout() {
          return new Promise((resolve, reject) => {
            logout().then(response => {
              window.localStorage.page = 0;
              window.localStorage.auditUser=undefined
              this.$router.push({ path: '/' });
              resolve()
            }).catch(error => {
              reject(error)
            })
          })
        },
        jump1(index, children, code) {
          window.localStorage.page = index;
          if (children.size != 0) {
            switch (code) {
              case '人员登记' :this.$router.push({path: '/Register'});break;
              case '报告阅片' :this.$router.push({path: '/Reportview'});break;
              case '影像阅片' :this.$router.push({path: '/Reportview2'});break;
//              case '统计查询' : this.$router.push({path: '/RTPositiveRate'});break;
              case '报告分配' : this.$router.push({name: 'ReportAssign'}); break;
              case '信息查询' : this.$router.push({name: 'SearchInfo'}); break;
              case '人员归档' : this.$router.push({name: 'Archive'}); break;
            }
          }
        },
        jump2(index, code) {
          window.localStorage.page = index;
          switch (code) {
            case '科室设置': this.$router.push({name: 'DeptSetting'}); break;
            case '设备类型': this.$router.push({name: 'EqpTypeSetting'}); break;
            case '设备管理': this.$router.push({name: 'EquipSetting'}); break;
            case '部位管理': this.$router.push({name: 'PartSetting'}); break;
            case '模板管理': this.$router.push({name: 'TemplateSetting'}); break;
            case '用户管理': this.$router.push({name: 'UserSetting'}); break;
            case '角色管理': this.$router.push({name: 'RoleSetting'}); break;
            case '收费项目维护': this.$router.push({name: 'FeeItemSetting'}); break;
            case '部位组管理': this.$router.push({name: 'PartGroupSetting'}); break;
            case '收费项目类型': this.$router.push({name: 'FeeTypeSetting'}); break;
            case '阳性率统计表': this.$router.push({name: 'PositiveRate'}); break;
          }
        },
        getTime() {
          var dateObj = new Date();

          var year = dateObj.getFullYear();//年
          var month = dateObj.getMonth()+1;//月  (注意：月份+1)
          var date = dateObj.getDate();//日
          var day = dateObj.getDay();
          var weeks = ["星期日","星期一","星期二","星期三","星期四","星期五","星期六"];
          var week = weeks[day];//根据day值，获取星期数组中的星期数。
          var hours = dateObj.getHours();//小时
          var minutes = dateObj.getMinutes();//分钟
          var seconds = dateObj.getSeconds();//秒

          if(month<10){
            month = "0"+month;
          }
          if(date<10){
            date = "0"+date;
          }
          if(hours<10){
            hours = "0"+hours;
          }
          if(minutes<10){
            minutes = "0"+minutes;
          }
          if(seconds<10){
            seconds = "0"+seconds;
          }

          var newDate = year+"-"+month+"-"+date+" "+hours+":"+minutes+":"+seconds+ " " +week;
          // document.getElementById("date1").innerHTML = newDate;//在div中写入时间
          this.nowTime = newDate;
          // setTimeout('getTime()', 1000);//每隔500ms执行一次getTime()
        }

      },
      filters:{
        icon(val) {
          if (val=='人员登记') {
            return img1;
          }else if (val=='报告阅片'){
            return img2;
          }else if (val=='字典维护'){
            return img3;
          }else if (val=='统计查询'){
            return img4;
          }else if (val=='系统设置'){
            return img5;
          }else if (val=='报告分配'){
            return img6;
          }else if (val=='信息查询'){
            return img7;
          }
        },
      },
      mounted (){
        var that=this;
        setInterval(function () {
          // console.log(this);
          that.getTime();
        },500);//每隔500ms执行一次getTime()
      }
    }
</script>

<style scoped>

  /*头部*/
  .ris_nav{
    height: 30px;
    line-height: 30px;
  }
  .nav_cont{
    min-width: 1300px;
    width: 96%;
    margin: 0 auto;
  }
  /*logo*/
  .nav_lofo{
    width: 20%;
    /*border: 1px solid #eee;*/
    height: 30px;
    float: left;
    overflow: hidden;
  }
  .nav_lofo>img{
    /*width: 100%;*/
    height: 100%;
  }
  /*导航*/
  .nav_ul{
    width: 65%;
    /*border: 1px solid #fff;*/
    float: left;
    height: 30px;
  }
  .nav_ul>li{
    width: 12%;
    float: left;
    color: #fff;
    text-align: center;
    position: relative;
    height: 100%;
  }
  .nav_ul li{
    cursor: pointer;
  }
  .nav_ul>li>a{
    font-size: 14px;
  }
  .nav_ul>li>p{
    padding-top: 10px;

  }
  .nav_ul>li>p>img{
    height: 14px;
  }
  .nav_ul>li>ul{
    position: absolute;
    left: 0;
    top:30px;
    width: 100%;
    /*display: none;*/
  }
  .nav_ul>li>ul>li{
    background-color: #373737;
    min-width: 100%;
    text-align: center;
    line-height: 30px;
    border-top:1px solid #eee;
  }
  .nav_avtive{
    background-color: #5f5f5f;
  }
  .nav_ul li:hover{
    background-color: #666;
  }

  .nav_search{
    width: 12%;
    float: right;
    box-sizing: border-box;
    height: 30px;
    text-align: right;
  }
  .nav_search>ul{
    width: 100%;
  }
  .nav_search>ul>li{
    width: 100%;
    float: left;
    text-align: center;
    height: 30px;
    cursor: pointer;
    position: relative;
    box-sizing: border-box;
    line-height: 30px;
    color: #fff;
  }
  /*.nav_search>ul>li>img{*/
    /*width: 20px;*/
    /*height: 20px;*/
    /*!*position: absolute;*!*/
    /*padding: 0px 15px;*/
  /*}*/
  .nav_search>ul li:hover{
    background-color: #666;
  }
  .nav_search>ul>li>ul{
    position: absolute;
    left: -50%;
    top: 30px;
    width: 150%;
    /*display: none;*/
  }
  .nav_search>ul>li>ul>li{
    background-color: #373737;
    border-top: 1px solid #eee;
    line-height: 30px;
    color: #fff;
  }





  /*底部*/
  .ris_footer{
    height: 30px;
    line-height: 30px;
    background-color: #e3e3e3;
    text-align: center;
    color: #999;
  }
  .ris_cont_head{
    height: 26px;
    width: 96%;
    background-color: #e5e5e5;
    color: #3f3f3f;
    line-height: 26px;
    margin-top: 50px;
    min-width: 1300px;
    padding: 0 2%;
  }
  .ris_cont_head_left{
    float: left;
    width: 40%;
  }
  .ris_cont_head_left p{
    display: inline-block;
    padding:0 30px;
  }
  .ris_cont_head_right{
    float: right;
    width: 40%;
    text-align: right;
  }
  .ris_cont_head_right p{
    display: inline-block;
    padding:0 30px;
  }
  .zhuxiaoLogin{
    /*background: url("../../../static/img/header/zhuxiao_03.png") no-repeat left center;*/
    /*background-size: 18px;*/
    cursor: pointer;
  }
  .zhuxiaoLogin>img{
    width: 14px;
    padding: 0 5px;
    position: relative;
    top: 3px;
  }
  .zhuxiaoLogin:hover{
    opacity: .8;
  }
  .ts_Text{
    /*background: url("../../../static/img/header/tishiText_06.png") no-repeat 16px center;*/
    /*background-size: 7px;*/
  }
  .ts_Text>img{
    width: 7px;
    padding: 0 8px;
    position: relative;
    top: 3px;
  }


  /*
  修改密码
  */
  .cp_modal{
    position: fixed;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    z-index: 999;
    background: rgba(0,0,0,.2);
  }
  .cp_modal>div{
    width: 400px;
    height: 300px;
    background: #fff;
    color: #666;
    position: absolute;
    left: 50%;
    top: 50%;
    margin-left: -200px;
    margin-top: -150px;
    border-radius: 10px;
    border: 1px solid #ddd;
  }
  .cp_head{
    text-align: center;
    line-height: 80px;
    font-size: 18px;
  }
  .cp_table{
    width: 75%;
    margin: 0px auto;
    line-height: 46px;
  }
  .cp_table tr td:nth-child(1){
    width: 35%;
    padding: 0 15px;
    text-align: center;
    text-align-last: justify;
  }
  .cp_table tr td:nth-child(2){
    width: 65%;
  }
  .cp_table tr td:nth-child(2) input{
    width: 90%;
    height: 30px;
  }
  .cp_footBtn{
    text-align: center;
  }
  .cp_footBtn button{
    width: 25%;
    margin: 10px 6%;
    height: 32px;
  }

</style>
